﻿
using System.Windows.Input;

namespace Simhopp.Client
{
    /// <summary>
    /// Container class for all commands used by WPF. The class uses standard WPF dispatching and routing. 
    /// </summary>
    public abstract class IPresenterBindings
    {

        #region WPF_COMMAND_NAMES
        public static RoutedCommand NextCompetitor { get; set; }
        public static RoutedCommand NextRound { get; set; }
        public static RoutedCommand SetScore  {get;set; }
        public static RoutedCommand AddJudge { get; set; }
        public static RoutedCommand RemoveJudge { get; set; }
        public static RoutedCommand ChangeLevelToHead { get; set; }
        public static RoutedCommand ChangeLevelToJudge { get; set; }
        public static RoutedCommand LogOn { get; set; }
        public static RoutedCommand LogOut { get; set; }
        public static RoutedCommand AddCompetitor { get; set; }
        public static RoutedCommand AddHeadjudge { get; set; }
        public static RoutedCommand RemoveHeadJudge { get; set; }
        public static RoutedCommand AddCompetition { get; set; }
        public static RoutedCommand RemoveCompetitor { get; set; }
        public static RoutedCommand Exit { get; set; }
        public static RoutedCommand Save { get; set; }
        public static RoutedCommand FinalizeConfiguration { get; set; }
        public static RoutedCommand Reconnect { get; set; }
        public static RoutedCommand SetActiveCompetition { get; set; }
        public static RoutedCommand CreateNewCompetition { get; set; }
        #endregion
        private CommandBindingCollection bindings;
        public CommandBindingCollection CommandBindings
        {
            get
            {
                return bindings;
            }
        }
        /// <summary>
        /// Sets up the routing and handling. The virtual inheritance ensures sure that the implementing classes functions are called from the static commands.
        /// </summary>
        protected IPresenterBindings()
        {
            bindings = new CommandBindingCollection();

            bindings.Add(new CommandBinding(NextCompetitor = new RoutedCommand("NextCompetitor",typeof(IPresenterBindings)), NextCompetitorHandler, CanHandleNextCompetitor));
            bindings.Add(new CommandBinding(NextRound = new RoutedCommand("NextRound", typeof(IPresenterBindings)), NextRoundHandler, CanHandleNextRound));
            bindings.Add(new CommandBinding(SetScore = new RoutedCommand("SetScore",typeof(IPresenterBindings)), SetScoreHandler, CanHandleSetScore));
            bindings.Add(new CommandBinding(LogOn = new RoutedCommand("LogOn", typeof(IPresenterBindings)), LogOnHandler, CanHandleLogOn));
            bindings.Add(new CommandBinding(LogOut = new RoutedCommand("LogOut", typeof(IPresenterBindings)), LogoutHandler, CanHandleLogout));
            bindings.Add(new CommandBinding(AddJudge = new RoutedCommand("AddJudge", typeof(IPresenterBindings)), AddJudgeHandler, CanHandleAddJudge));
            bindings.Add(new CommandBinding(ChangeLevelToHead = new RoutedCommand("ChangeJudgeLevel", typeof(IPresenterBindings)), ChangeLevelToHeadHandler, CanHandleChangeLevel));
            bindings.Add(new CommandBinding(ChangeLevelToJudge = new RoutedCommand("ChangeJudgeLevel", typeof(IPresenterBindings)), ChangeLevelToJudgeHandler, CanHandleChangeLevel));
            bindings.Add(new CommandBinding(AddCompetitor = new RoutedCommand("AddCompetitor", typeof(IPresenterBindings)), AddCompetitorHandler, CanHandleAddCompetitor));
            bindings.Add(new CommandBinding(AddHeadjudge = new RoutedCommand("AddHeadjudge", typeof(IPresenterBindings)), AddHeadJudgeHandler, CanHandleAddHeadJudge));
            bindings.Add(new CommandBinding(Exit = new RoutedCommand("Exit", typeof(IPresenterBindings)), ExitHandler, CanHandleExit));
            bindings.Add(new CommandBinding(Save = new RoutedCommand("Save", typeof(IPresenterBindings)), SaveHandler, CanHandleSave));
            bindings.Add(new CommandBinding(FinalizeConfiguration = new RoutedCommand("FinalizeConfiguration", typeof(IPresenterBindings)), FinalizeConfigurationHandler, CanHandleFinalizeConfiguration));
            bindings.Add(new CommandBinding(Reconnect = new RoutedCommand("Reconnect", typeof (IPresenterBindings)), ReconnectHandler, CanHandleReconnect));
            bindings.Add(new CommandBinding(SetActiveCompetition = new RoutedCommand("SetActiveCompetition", typeof(IPresenterBindings)), SetActiveCompetitionHandler, CanHandleSetActiveCompetition));
            bindings.Add(new CommandBinding(CreateNewCompetition = new RoutedCommand("CreateNewCompetition", typeof(IPresenterBindings)), CreateNewCompetitionHandler, CanHandleCreateNewCompetition));

            bindings.Add(new CommandBinding(RemoveCompetitor = new RoutedCommand("RemoveCompetitor", typeof(IPresenterBindings)), RemoveCompetitorHandler, CanHandleRemoveCompetitor));
            bindings.Add(new CommandBinding(RemoveHeadJudge = new RoutedCommand("RemoveHeadJudge", typeof(IPresenterBindings)), RemoveHeadJudgeHandler, CanHandleRemoveHeadJudge));
            bindings.Add(new CommandBinding(RemoveJudge = new RoutedCommand("RemoveJudge", typeof(IPresenterBindings)), RemoveJudgeHandler, CanHandleRemoveJudge));
            foreach (CommandBinding binding in bindings)
	        {
                CommandManager.RegisterClassCommandBinding(typeof(Presenter), binding);
	        }
        }
        #region Handlers
        /// <summary>
        /// Linked to the FinalizeConfiguration command. See the implementing class' details for more information.
        /// </summary>
        /// <param name="sender">The invoking element</param>
        /// <param name="e">The execution parameters.</param>
        protected abstract void CanHandleFinalizeConfiguration(object sender, CanExecuteRoutedEventArgs e);

        /// <summary>
        /// Linked to the FinalizeConfiguration command. See the implementing class' details for more information.
        /// </summary>
        /// <param name="sender">The invoking element</param>
        /// <param name="e">The execution parameters.</param>
        protected abstract void FinalizeConfigurationHandler(object sender, ExecutedRoutedEventArgs e);

        /// <summary>
        /// Linked to the NextCompetitor command. See the implementing class' details for more information.
        /// </summary>
        /// <param name="sender">The invoking element</param>
        /// <param name="e">The execution parameters.</param>
        protected abstract void NextCompetitorHandler(object sender, ExecutedRoutedEventArgs e);/// <summary>
        /// Linked to the NextCompetitor command. See the implementing class' details for more information.
        /// </summary>
        /// <param name="sender">The invoking element</param>
        /// <param name="e">The execution parameters.</param>
        protected abstract void CanHandleNextCompetitor(object sender, CanExecuteRoutedEventArgs e);

        /// <summary>
        /// Linked to the NextRound command. See the implementing class' details for more information.
        /// </summary>
        /// <param name="sender">The invoking element</param>
        /// <param name="e">The execution parameters.</param>
        protected abstract void NextRoundHandler(object sender, ExecutedRoutedEventArgs e);
        /// <summary>
        /// Linked to the NextRound command. See the implementing class' details for more information.
        /// </summary>
        /// <param name="sender">The invoking element</param>
        /// <param name="e">The execution parameters.</param>
        protected abstract void CanHandleNextRound(object sender, CanExecuteRoutedEventArgs e);


        /// <summary>
        /// Linked to the SetScore command. See the implementing class' details for more information.
        /// </summary>
        /// <param name="sender">The invoking element</param>
        /// <param name="e">The execution parameters.</param>
        protected abstract void SetScoreHandler(object sender, ExecutedRoutedEventArgs e);
        /// <summary>
        /// Linked to the SetScore command. See the implementing class' details for more information.
        /// </summary>
        /// <param name="sender">The invoking element</param>
        /// <param name="e">The execution parameters.</param>
        protected abstract void CanHandleSetScore(object sender, CanExecuteRoutedEventArgs e);


        /// <summary>
        /// Linked to the LogOn command. See the implementing class' details for more information.
        /// </summary>
        /// <param name="sender">The invoking element</param>
        /// <param name="e">The execution parameters.</param>
        protected abstract void LogOnHandler(object sender, ExecutedRoutedEventArgs e);
        /// <summary>
        /// Linked to the LogOn command. See the implementing class' details for more information.
        /// </summary>
        /// <param name="sender">The invoking element</param>
        /// <param name="e">The execution parameters.</param>
        protected abstract void CanHandleLogOn(object sender, CanExecuteRoutedEventArgs e);


        /// <summary>
        /// Linked to the LogOut command. See the implementing class' details for more information.
        /// </summary>
        /// <param name="sender">The invoking element</param>
        /// <param name="e">The execution parameters.</param>
        protected abstract void LogoutHandler(object sender, ExecutedRoutedEventArgs e);
        /// <summary>
        /// Linked to the LogOut command. See the implementing class' details for more information.
        /// </summary>
        /// <param name="sender">The invoking element</param>
        /// <param name="e">The execution parameters.</param>
        protected abstract void CanHandleLogout(object sender, CanExecuteRoutedEventArgs e);


        /// <summary>
        /// Linked to the AddJudge command. See the implementing class' details for more information.
        /// </summary>
        /// <param name="sender">The invoking element</param>
        /// <param name="e">The execution parameters.</param>
        protected abstract void AddJudgeHandler(object sender, ExecutedRoutedEventArgs e);
        /// <summary>
        /// Linked to the AddJudge command. See the implementing class' details for more information.
        /// </summary>
        /// <param name="sender">The invoking element</param>
        /// <param name="e">The execution parameters.</param>
        protected abstract void CanHandleAddJudge(object sender, CanExecuteRoutedEventArgs e);

        /// <summary>
        /// Linked to the ChangeLevelToHead command. See the implementing class' details for more information.
        /// </summary>
        /// <param name="sender">The invoking element</param>
        /// <param name="e">The execution parameters.</param>
        protected abstract void ChangeLevelToHeadHandler(object sender, ExecutedRoutedEventArgs e);/// <summary>
        /// Linked to the ChangeLevelToJudge command. See the implementing class' details for more information.
        /// </summary>
        /// <param name="sender">The invoking element</param>
        /// <param name="e">The execution parameters.</param>
        protected abstract void ChangeLevelToJudgeHandler(object sender, ExecutedRoutedEventArgs e);
        /// <summary>
        /// Linked to the ChangeLevelToHead & ChangeLevelToJudge command. See the implementing class' details for more information.
        /// </summary>
        /// <param name="sender">The invoking element</param>
        /// <param name="e">The execution parameters.</param>
        protected abstract void CanHandleChangeLevel(object sender, CanExecuteRoutedEventArgs e);
        /// <summary>
        /// Linked to the AddCompetitor command. See the implementing class' details for more information.
        /// </summary>
        /// <param name="sender">The invoking element</param>
        /// <param name="e">The execution parameters.</param>
        protected abstract void AddCompetitorHandler(object sender, ExecutedRoutedEventArgs e);
        /// <summary>
        /// Linked to the AddCompetitor command. See the implementing class' details for more information.
        /// </summary>
        /// <param name="sender">The invoking element</param>
        /// <param name="e">The execution parameters.</param>
        protected abstract void CanHandleAddCompetitor(object sender, CanExecuteRoutedEventArgs e);



        /// <summary>
        /// Linked to the AddHeadJudge command. See the implementing class' details for more information.
        /// </summary>
        /// <param name="sender">The invoking element</param>
        /// <param name="e">The execution parameters.</param>
        protected abstract void AddHeadJudgeHandler(object sender, ExecutedRoutedEventArgs e);
        /// <summary>
        /// Linked to the AddHeadJudge command. See the implementing class' details for more information.
        /// </summary>
        /// <param name="sender">The invoking element</param>
        /// <param name="e">The execution parameters.</param>
        protected abstract void CanHandleAddHeadJudge(object sender, CanExecuteRoutedEventArgs e);
        /// <summary>
        /// Linked to the Exit command. See the implementing class' details for more information.
        /// </summary>
        /// <param name="sender">The invoking element</param>
        /// <param name="e">The execution parameters.</param>
        protected abstract void ExitHandler(object sender, ExecutedRoutedEventArgs e);
        /// <summary>
        /// Linked to the Exit command. See the implementing class' details for more information.
        /// </summary>
        /// <param name="sender">The invoking element</param>
        /// <param name="e">The execution parameters.</param>
        protected abstract void CanHandleExit(object sender, CanExecuteRoutedEventArgs e);

        /// <summary>
        /// Linked to the Save command. See the implementing class' details for more information.
        /// </summary>
        /// <param name="sender">The invoking element</param>
        /// <param name="e">The execution parameters.</param>
        protected abstract void SaveHandler(object sender, ExecutedRoutedEventArgs e);

        /// <summary>
        /// Linked to the Save command. See the implementing class' details for more information.
        /// </summary>
        /// <param name="sender">The invoking element</param>
        /// <param name="e">The execution parameters.</param>
        protected abstract void CanHandleSave(object sender, CanExecuteRoutedEventArgs e);




        /// <summary>
        /// Linked to the Reconnect command. See the implementing class' details for more information.
        /// </summary>
        /// <param name="sender">The invoking element</param>
        /// <param name="e">The execution parameters.</param>
        protected abstract void ReconnectHandler(object sender, ExecutedRoutedEventArgs e);

        /// <summary>
        /// Linked to the Reconnect command. See the implementing class' details for more information.
        /// </summary>
        /// <param name="sender">The invoking element</param>
        /// <param name="e">The execution parameters.</param>
        protected abstract void CanHandleReconnect(object sender, CanExecuteRoutedEventArgs e);


        /// <summary>
        /// Linked to the RemoveCompetitor command. See the implementing class' details for more information.
        /// </summary>
        /// <param name="sender">The invoking element</param>
        /// <param name="e">The execution parameters.</param>
        protected abstract void RemoveCompetitorHandler(object sender, ExecutedRoutedEventArgs e);


        /// <summary>
        /// Linked to the RemoveCompetitor command. See the implementing class' details for more information.
        /// </summary>
        /// <param name="sender">The invoking element</param>
        /// <param name="e">The execution parameters.</param>
        protected abstract void CanHandleRemoveCompetitor(object sender, CanExecuteRoutedEventArgs e);



        /// <summary>
        /// Linked to the RemoveHeadJudge command. See the implementing class' details for more information.
        /// </summary>
        /// <param name="sender">The invoking element</param>
        /// <param name="e">The execution parameters.</param>
        protected abstract void RemoveHeadJudgeHandler(object sender, ExecutedRoutedEventArgs e);



        /// <summary>
        /// Linked to the RemoveHeadJudge command. See the implementing class' details for more information.
        /// </summary>
        /// <param name="sender">The invoking element</param>
        /// <param name="e">The execution parameters.</param>
        protected abstract void CanHandleRemoveHeadJudge(object sender, CanExecuteRoutedEventArgs e);




        /// <summary>
        /// Linked to the RemoveJudge command. See the implementing class' details for more information.
        /// </summary>
        /// <param name="sender">The invoking element</param>
        /// <param name="e">The execution parameters.</param>
        protected abstract void RemoveJudgeHandler(object sender, ExecutedRoutedEventArgs e);
        /// <summary>
        /// Linked to the RemoveJudge command. See the implementing class' details for more information.
        /// </summary>
        /// <param name="sender">The invoking element</param>
        /// <param name="e">The execution parameters.</param>
        protected abstract void CanHandleRemoveJudge(object sender, CanExecuteRoutedEventArgs e);

        /// <summary>
        /// Linked to the SetActiveCompetition command. See the implementing class' details for more information.
        /// </summary>
        /// <param name="sender">The invoking element</param>
        /// <param name="e">The execution parameters.</param>
        protected abstract void SetActiveCompetitionHandler(object sender, ExecutedRoutedEventArgs e);
        /// <summary>
        /// Linked to the SetActiveCompetition command. See the implementing class' details for more information.
        /// </summary>
        /// <param name="sender">The invoking element</param>
        /// <param name="e">The execution parameters.</param>
        protected abstract void CanHandleSetActiveCompetition(object sender, CanExecuteRoutedEventArgs e);
        /// <summary>
        /// Linked to the CreateNewCompetition command. See the implementing class' details for more information.
        /// </summary>
        /// <param name="sender">The invoking element</param>
        /// <param name="e">The execution parameters.</param>
        protected abstract void CreateNewCompetitionHandler(object sender, ExecutedRoutedEventArgs e);
        /// <summary>
        /// Linked to the CreateNewCompetition command. See the implementing class' details for more information.
        /// </summary>
        /// <param name="sender">The invoking element</param>
        /// <param name="e">The execution parameters.</param>
        protected abstract void CanHandleCreateNewCompetition(object sender, CanExecuteRoutedEventArgs e);

        #endregion

        #region OTHER_BINDINGS

        #endregion
    }
}
